package org.nanfang.lianxi.cunzhe;

import java.util.Objects;
import java.util.concurrent.locks.Lock;

public class MyRunnable implements Runnable{
    private Cunzi cunzi;
    private String  user;
    private int money;

    private static final Objects lock = (Objects) new Object();
    private MyRunnable(){
        super();
    }
    public MyRunnable(Cunzi cunzi, String user, int money) {
        this.cunzi = cunzi;
        this.user = user;
        this.money = money;
    }

    public Cunzi getCunzi() {
        return cunzi;
    }

    public void setCunzi(Cunzi cunzi) {
        this.cunzi = cunzi;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

//    @Override
//    public void run() {
//       cunzi.getMoney(user,money);
//    }
    @Override
    public void run() {
        synchronized (lock){
            cunzi.getMoney(user,money);
        }
    }
}
